﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Web.Mvc;
using Prodma.DataAccess.Database;
using Prodma.DataAccess.Models;
using Prodma.DataAccess.Helper.Enumerators;

namespace Prodma.DataAccess.DataService.ListService
{
    public static class StateList
    {

        private static DataContext context = new DataContext();

        public static SelectList GetList(StateType type)
        {
            int t = Convert.ToInt32(type);
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from state in context.LK_DURUM
                            //where state.tb_StateType.Id == t
                            select state);
                SelectList selectList = new SelectList(list.ToDictionary(x => x.ID, z => z.AD), "Key", "Value");

                return selectList;
            }
        }
        public static SelectList GetList(StateType type, int id)
        {
            int t = Convert.ToInt32(type);
            DataContext context = new DataContext();
            using (context)
            {
                var list = (from state in context.LK_DURUM
                            //where state.tb_StateType.Id == t
                            select state);
                SelectList selectList = new SelectList(list.ToDictionary(x => x.ID, z => z.AD), "Key", "Value", id);

                return selectList;
            }
        }
    }
}
